<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>用户角色</title>
		[#include "/html/include/easyuicss.html" /]
		[#include "/html/include/easyuijs.html" /]
	</head>
	<body class="easyui-layout" data-options="fit:true">
		[#assign xzcs=JspTaglibs['/WEB-INF/xzcs.tld'] /]
		<form id="userRoleForm" class="easyui-form" method="post" data-options="novalidate:true">
			<input type="hidden" name="userId" value="${RequestParameters['userId']}" />
			<table class="tblEidt">
				<tr>
					<td>
						[@xzcs.checkboxlist id="roleId" name="roleId" value="${roleIds}" cssClass="easyui-validatebox"
						columns="4" delims="," otherAttr='data-options="required:true" validType="Group[\'必须选择一项\',\'roleId\']" '
						list=Request['roles'] checkboxLabel="role_name" checkboxValue="role_id"]
						[/@xzcs.checkboxlist]
					</td>
				</tr>
			</table>
			<div class="edit-btn-group">
				<a href="javascript:;" class="easyui-linkbutton"
				   data-options="iconCls:'icon-ok'" style="width:80px"
				   onclick="saveUserRole(this);">保存</a>
				&nbsp;&nbsp;
				<a href="javascript:;" class="easyui-linkbutton"
				   data-options="iconCls:'icon-cancel'" style="width:80px"
				   onclick="closeWindow();">关闭</a>
			</div>
		</form>
	</body>
    <script type="text/javascript">
		var index = parent.layer.getFrameIndex(window.name);
		function closeWindow(){
			parent.layer.close(index);
		}
		function saveUserRole(obj){
			$(obj).linkbutton('disable');
			$('#userRoleForm').form('submit', {
				url: '${app}/sysmgr/user/saveUserRole.do',
				onSubmit: function () {
					var valid = $(this).form('enableValidation').form('validate');
					if (!valid) {
						$(obj).linkbutton('enable');
					}
					return valid;
				},
				success: function (data) {
					var result = $.parseJSON(data);
					parent.easyui.msgShow('系统提醒', result.msg, 3000, 250, 100);
					$(obj).linkbutton('enable');
					if (result.result == 1) {
						parent.layer.close(index);
					}
				}
			});
		}
    </script>
</html>